<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>搜索</title>
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="applicable-device" content="mobile" />
		<meta name="apple-mobile-web-app-title" content="" />
		<!-- 添加到主屏后的标题（iOS 6 新增） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 是否启用 WebApp 全屏模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="author" content="Jack" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../../js/flexible.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/jquery-weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/car.css" />
		<link rel="stylesheet" type="text/css" href="../../style/main.css"/>
		<link rel="stylesheet" type="text/css" href="../../style/icon.css"/>
		<link rel="stylesheet" type="text/css" href="../../style/icon_font/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../../swiper/css/swiper.min.css" />
		<link rel="stylesheet" type="text/css" href="../../style/pub_foot.css" />
		<link rel="stylesheet" type="text/css" href="../../style/null.css"/>
	</head>

	<body>

		<div class="search-page-postion">
			<div class="header-nav">
				<div class="cen-mony">
					<div class="header-flex">
						<i class="return-2" onclick="window.history.go(-1)"></i>
					</div>
					<div class="header-flex">搜索</div>
					<div class="header-flex"></div>
				</div>
			</div>
			<div class="search-page-flex">
				<span class="search-flex1">
				<i class="iconfont icon-Group- search-icon"></i>
				<input type="text" class="search-page-input" placeholder="请输入搜索内容"/>
			</span>
				<span class="search-flex2" onclick="data_obj.search_fn()">搜索</span>
			</div>
		</div>

		<div style="margin-top: 2.8rem;">
			<div class="search-result-cen" id="search-return">
				<!--<div class="search-result-flex">
					<div><img src="../../images/inxe-img.png" class="inxe-img" /></div>
					<div class="search-result-info">
						<div class="car-name-search">蒙迪欧混动版</div>
						<div class="car-introduce">首付一万新车带回家</div>
						<div class="car-pic">￥28.08万</div>
					</div>
				</div>
				<div class="search-result-flex">
					<div><img src="../../images/inxe-img.png" class="inxe-img" /></div>
					<div class="search-result-info">
						<div class="car-name-search">蒙迪欧混动版</div>
						<div class="car-introduce">首付一万新车带回家</div>
						<div class="car-pic">￥28.08万</div>
					</div>
				</div>-->
			</div>
		</div>
		
		<!--没有信息的时候-->
		<div class="null-data">
			<img src="../../images/null_data.png" alt="" />
			<div id="available">暂无数据~</div>
		</div>

	</body>
	<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/weiUI/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/api_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/port_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../swiper/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/md5/access.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function(){
			if(GetRequest().catid){
				data_obj.goods_list(0);
			}
		})
		
		var data_length='';//总页数
	    var page=1;//当前页
	    var pageSize=10;//每页显示几条
		
		var loading = false;  //状态标记 这个变量主要是用来控制触发次数，官网也有说明，事件可能会触发多次
	    $(document.body).infinite().on("infinite", function() {
	        $("#loading").css("display","block");//显示 加载中图标
	        if(loading) return;
	        loading = true;	            
            if(data_length<10||data_length==0){
	            $(document.body).destroyInfinite();//到最后一页时，销毁它
	            $("#loading>i").css("display","none");
	            $("#loading>span").html("到底啦~").css("color","#BDBDBD");
            }else{
				page++;
            	data_obj.goods_list(page);
            }
	    });
		var data_obj = {
			goods_list:function(num){
				$.ajax({
				url: config_URL.api+URL.goodsList, //请求的url地址
				dataType: "json", //返回格式为json
				data:{
					access_token:'6de687d898834bf3bf6c04ba278c1c07',
					page: page,
					list_rows: pageSize,
					keywords:$('.search-page-input').val(),
					catid:GetRequest().catid
					
				},
				type: "POST", //请求方式
				success: function(res) {
					console.log(res)
					var data = res.data;
					var search_list = '';
					if(res.code==0){
							data_length =  data.length;
	            			if(data.length == 0) {
								$('.null-data').show();
							}else{
								$('.null-data').hide();
							}
						for(var i in data){
							search_list+=
							'				<div class="search-result-flex" onclick="data_obj.details_fn('+data[i].id+')">'+
							'					<div><img src=" '+data[i].img+'" class="inxe-img" /></div>'+
							'					<div class="search-result-info">'+
							'						<div class="car-name-search">'+data[i].title+'</div>'+
							'						<div class="car-introduce">'+data[i].ftitle+'</div>'+
							'						<div class="car-pic">￥'+figureChange(data[i].money)+'</div>'+
							'					</div>'+
							'				</div>';
						}
          				if(num==1){
          					$('#search-return').html(search_list);
          				}else{
          					$('#search-return').append(search_list);
          				}
						
						loading = false;//会多次触发，所以 需要请求完成数据 才能继续触发	            
	           			$("#loading").css("display","none");//数据加载完隐藏加载提示
					}else{
						$.toast(res.msg, "text");
					}
					
					
				},
				error: function(rul) {
					console.log('网络出错')
				}
			});
			},
			search_fn:function(){
				data_obj.goods_list(1);
			},
			details_fn:function(gid){
				window.location.href='car_details.html?gid='+ gid
			}
		}
	</script>
</html>